package com.broada.apm.dao.impl;

import java.util.List;

import com.broada.apm.dao.TransactionDao;
import com.broada.apm.model.TransactionChannel;
import com.broada.apm.model.TransactionType;

public class MysqlTransactionDao extends MysqlAbstractDao implements TransactionDao {

	public static final String USER_NAMESPACE = "com.broada.apm.dao.TransactionDao.";

	@Override
	public void addTransactionChannel(TransactionChannel transactionChannel) {
		getSqlSession().insert(USER_NAMESPACE + "addTransactionChannel", transactionChannel);
	}

	@Override
	public void addTransactionType(TransactionType transactionType) {
		getSqlSession().insert(USER_NAMESPACE + "addTransactionType", transactionType);
	}

	@Override
	public void addServiceTransactionTypeMap(TransactionType transactionType) {
		getSqlSession().insert(USER_NAMESPACE + "addAppTransactionTypeMap", transactionType);
	}
	
	@Override
	public List<TransactionChannel> getTransactionChannelByAppId(String appId) {
		return getSqlSession().selectList(USER_NAMESPACE + "getTransactionChannel", appId);
	}

	@Override
	public List<TransactionType> getTransactionTypeByAppId(String appId) {
		return getSqlSession().selectList(USER_NAMESPACE + "getTransactionType", appId);
	}

	@Override
	public List<TransactionType> getTypeByCondition(TransactionType transactionType) {
		return getSqlSession().selectList(USER_NAMESPACE + "getTransactionTypeByCondition", transactionType);
	}

	@Override
	public List<TransactionChannel> getChannelByCondition(TransactionChannel transactionChannel) {
		return getSqlSession().selectList(USER_NAMESPACE + "getTransactionChannelByCondition", transactionChannel);
	}

	@Override
	public List<String> getServiceIdByL7SubProto(TransactionType transactionType) {
		return getSqlSession().selectList(USER_NAMESPACE + "getAppIdByL7SubProto", transactionType);
	}

	@Override
	public void updateTransactionChannel(TransactionChannel transactionChannel) {
		getSqlSession().insert(USER_NAMESPACE + "updateTransactionChannel", transactionChannel);
	}

	@Override
	public void updateTransactionType(TransactionType transactionType) {
		getSqlSession().insert(USER_NAMESPACE + "updateTransactionType", transactionType);
	}

	@Override
	public void deleteTransactionChannel(TransactionChannel transactionChannel) {
		getSqlSession().delete(USER_NAMESPACE + "deleteTransactionChannel", transactionChannel);
	}

	@Override
	public void deleteTransactionType(TransactionType transactionType) {
		getSqlSession().delete(USER_NAMESPACE + "deleteTransactionType", transactionType);
	}
}
